<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"wrr123.github.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="jdk1.8如何解析和格式化日期解析日期和时间123String str &#x3D; &quot;1986-04-08 12:30&quot;;DateTimeFormatter formatter &#x3D; DateTimeFormatter.ofPattern(&quot;yyyy-MM-dd HH:mm&quot;);LocalDateTime dateTime &#x3D; LocalDateTime.parse">
<meta property="og:type" content="article">
<meta property="og:title" content="faq-java">
<meta property="og:url" content="https://wrr123.github.io/2020/07/01/faq-java/index.html">
<meta property="og:site_name" content="一缕烟气">
<meta property="og:description" content="jdk1.8如何解析和格式化日期解析日期和时间123String str &#x3D; &quot;1986-04-08 12:30&quot;;DateTimeFormatter formatter &#x3D; DateTimeFormatter.ofPattern(&quot;yyyy-MM-dd HH:mm&quot;);LocalDateTime dateTime &#x3D; LocalDateTime.parse">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-07-01T07:04:20.000Z">
<meta property="article:modified_time" content="2022-02-18T02:52:04.409Z">
<meta property="article:author" content="田园隐士">
<meta property="article:tag" content="java">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://wrr123.github.io/2020/07/01/faq-java/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>faq-java | 一缕烟气</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="一缕烟气" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">一缕烟气</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">沧海月明珠有泪，蓝田日暖玉生烟</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/07/01/faq-java/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          faq-java
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-01 15:04:20" itemprop="dateCreated datePublished" datetime="2020-07-01T15:04:20+08:00">2020-07-01</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FAQ/" itemprop="url" rel="index"><span itemprop="name">FAQ</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h4 id="jdk1-8如何解析和格式化日期"><a href="#jdk1-8如何解析和格式化日期" class="headerlink" title="jdk1.8如何解析和格式化日期"></a>jdk1.8如何解析和格式化日期</h4><h5 id="解析日期和时间"><a href="#解析日期和时间" class="headerlink" title="解析日期和时间"></a>解析日期和时间</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">String</span> <span class="variable">str</span> <span class="operator">=</span> <span class="string">&quot;1986-04-08 12:30&quot;</span>;</span><br><span class="line"><span class="type">DateTimeFormatter</span> <span class="variable">formatter</span> <span class="operator">=</span> DateTimeFormatter.ofPattern(<span class="string">&quot;yyyy-MM-dd HH:mm&quot;</span>);</span><br><span class="line"><span class="type">LocalDateTime</span> <span class="variable">dateTime</span> <span class="operator">=</span> LocalDateTime.parse(str, formatter);</span><br></pre></td></tr></table></figure>
<h5 id="格式化日期和时间"><a href="#格式化日期和时间" class="headerlink" title="格式化日期和时间"></a>格式化日期和时间</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">DateTimeFormatter</span> <span class="variable">formatter</span> <span class="operator">=</span> DateTimeFormatter.ofPattern(<span class="string">&quot;yyyy-MM-dd HH:mm&quot;</span>);</span><br><span class="line"><span class="type">LocalDateTime</span> <span class="variable">dateTime</span> <span class="operator">=</span> LocalDateTime.of(<span class="number">1986</span>, Month.APRIL, <span class="number">8</span>, <span class="number">12</span>, <span class="number">30</span>);</span><br><span class="line"><span class="type">String</span> <span class="variable">formattedDateTime</span> <span class="operator">=</span> dateTime.format(formatter); <span class="comment">// &quot;1986-04-08 12:30&quot;</span></span><br></pre></td></tr></table></figure>
<h4 id="Java8中Date与LocalDateTime、LocalDate、LocalTime之间的互转"><a href="#Java8中Date与LocalDateTime、LocalDate、LocalTime之间的互转" class="headerlink" title="Java8中Date与LocalDateTime、LocalDate、LocalTime之间的互转"></a>Java8中Date与LocalDateTime、LocalDate、LocalTime之间的互转</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 01. java.util.Date --&gt; java.time.LocalDateTime</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">UDateToLocalDateTime</span><span class="params">()</span> &#123;</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">java</span>.util.Date();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> date.toInstant();</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">LocalDateTime</span> <span class="variable">localDateTime</span> <span class="operator">=</span> LocalDateTime.ofInstant(instant, zone);</span><br><span class="line">&#125;</span><br><span class="line">	</span><br><span class="line"><span class="comment">// 02. java.util.Date --&gt; java.time.LocalDate</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">UDateToLocalDate</span><span class="params">()</span> &#123;</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">java</span>.util.Date();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> date.toInstant();</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">LocalDateTime</span> <span class="variable">localDateTime</span> <span class="operator">=</span> LocalDateTime.ofInstant(instant, zone);</span><br><span class="line">    <span class="type">LocalDate</span> <span class="variable">localDate</span> <span class="operator">=</span> localDateTime.toLocalDate();</span><br><span class="line">&#125;</span><br><span class="line">	</span><br><span class="line"><span class="comment">// 03. java.util.Date --&gt; java.time.LocalTime</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">UDateToLocalTime</span><span class="params">()</span> &#123;</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">java</span>.util.Date();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> date.toInstant();</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">LocalDateTime</span> <span class="variable">localDateTime</span> <span class="operator">=</span> LocalDateTime.ofInstant(instant, zone);</span><br><span class="line">    <span class="type">LocalTime</span> <span class="variable">localTime</span> <span class="operator">=</span> localDateTime.toLocalTime();</span><br><span class="line">&#125;</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line"><span class="comment">// 04. java.time.LocalDateTime --&gt; java.util.Date</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">LocalDateTimeToUdate</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="type">LocalDateTime</span> <span class="variable">localDateTime</span> <span class="operator">=</span> LocalDateTime.now();</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> localDateTime.atZone(zone).toInstant();</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> Date.from(instant);</span><br><span class="line">&#125;</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line"><span class="comment">// 05. java.time.LocalDate --&gt; java.util.Date</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">LocalDateToUdate</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="type">LocalDate</span> <span class="variable">localDate</span> <span class="operator">=</span> LocalDate.now();</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> localDate.atStartOfDay().atZone(zone).toInstant();</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> Date.from(instant);</span><br><span class="line">&#125;</span><br><span class="line">	</span><br><span class="line"><span class="comment">// 06. java.time.LocalTime --&gt; java.util.Date</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">LocalTimeToUdate</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="type">LocalTime</span> <span class="variable">localTime</span> <span class="operator">=</span> LocalTime.now();</span><br><span class="line">    <span class="type">LocalDate</span> <span class="variable">localDate</span> <span class="operator">=</span> LocalDate.now();</span><br><span class="line">    <span class="type">LocalDateTime</span> <span class="variable">localDateTime</span> <span class="operator">=</span> LocalDateTime.of(localDate, localTime);</span><br><span class="line">    <span class="type">ZoneId</span> <span class="variable">zone</span> <span class="operator">=</span> ZoneId.systemDefault();</span><br><span class="line">    <span class="type">Instant</span> <span class="variable">instant</span> <span class="operator">=</span> localDateTime.atZone(zone).toInstant();</span><br><span class="line">    java.util.<span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> Date.from(instant);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="http错误代码"><a href="#http错误代码" class="headerlink" title="http错误代码"></a>http错误代码</h4><ol>
<li><h5 id="400"><a href="#400" class="headerlink" title="400"></a>400</h5><p>请求无效（bad request），出现这个请求报错说明请求没有进入到后台服务中</p>
<p>原因：</p>
<ul>
<li>前端提交数据的字段名称或者字段类型和后台的实体类不一致，导致无法封装。</li>
<li>前端提交到后台的数据应该是json字符串类型，而前端没有将对象转化为字符串类型。</li>
</ul>
<p>解决方案：</p>
<ul>
<li>对照字段名称、类型，保证一致性</li>
<li>使用<code>JSON.stringify(param)</code>将前端传递的对象转化为字符串。</li>
</ul>
</li>
</ol>
<h4 id="EasyPOI导出excel文件时，若不想导出表头，怎么设置？"><a href="#EasyPOI导出excel文件时，若不想导出表头，怎么设置？" class="headerlink" title="EasyPOI导出excel文件时，若不想导出表头，怎么设置？"></a>EasyPOI导出excel文件时，若不想导出表头，怎么设置？</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">ExportParams</span> <span class="variable">exportParams</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ExportParams</span>(<span class="string">&quot;支付宝账单&quot;</span>, <span class="string">&quot;支付宝账单&quot;</span>);</span><br><span class="line">List&lt;KnsAliBillVo&gt; list = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">workbook = ExcelExportUtil.exportExcel(exportParams, KnsAliBillVo.class, list);</span><br><span class="line"><span class="comment">// 如果不想导出表头那一行，可以设置表头字符串参数为null即可。</span></span><br><span class="line"><span class="type">ExportParams</span> <span class="variable">exportParams</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ExportParams</span>(<span class="literal">null</span> , <span class="string">&quot;支付宝账单&quot;</span>);</span><br></pre></td></tr></table></figure>
<h4 id="java在同一行代码定义多个变量"><a href="#java在同一行代码定义多个变量" class="headerlink" title="java在同一行代码定义多个变量"></a>java在同一行代码定义多个变量</h4><p>一个栗子：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 同一行定义多个同类型的变量</span></span><br><span class="line"><span class="type">String</span> <span class="variable">a</span> <span class="operator">=</span> <span class="string">&quot;Hello&quot;</span>, c = <span class="string">&quot;hello&quot;</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">x</span> <span class="operator">=</span> <span class="number">5</span>, y = <span class="number">5</span>;</span><br></pre></td></tr></table></figure>
<h4 id="i-和-i-的区别"><a href="#i-和-i-的区别" class="headerlink" title="++i 和 i++ 的区别"></a>++i 和 i++ 的区别</h4><p>i++ 和 ++i 都是自增运算符，<code>i++</code> 有时被称作 <strong>后加运算符</strong> ，<code>++i</code> 被称作 <strong>前加运算符 。</strong></p>
<ul>
<li><code>i++</code> 是先赋值，再运算(自增长 1)</li>
<li><code>++i</code> 是先运算(自增长 1)，再赋值</li>
</ul>
<h5 id="讨论-i-与-i-的效率"><a href="#讨论-i-与-i-的效率" class="headerlink" title="讨论 i++ 与 ++i 的效率"></a>讨论 i++ 与 ++i 的效率</h5><blockquote>
<p>理论上，经过编译器优化后 i++ 与 ++i 的效率几乎一样，实际测试，++i 效率高于 i++。</p>
</blockquote>
<h4 id="spring中的注解-Component-Repository-Service-Controller-等标注的默认-Bean-名称"><a href="#spring中的注解-Component-Repository-Service-Controller-等标注的默认-Bean-名称" class="headerlink" title="spring中的注解 @Component, @Repository, @Service, @Controller 等标注的默认 Bean 名称"></a>spring中的注解 <code>@Component, @Repository, @Service, @Controller</code> 等标注的默认 Bean 名称</h4><p><strong>都是小写开头的类名</strong></p>
<h4 id="报错信息java-lang-NoSuchMethodError-org-json-JSONObject-put-String-Collection"><a href="#报错信息java-lang-NoSuchMethodError-org-json-JSONObject-put-String-Collection" class="headerlink" title="报错信息java.lang.NoSuchMethodError:org.json.JSONObject.put(String, Collection)"></a>报错信息<code>java.lang.NoSuchMethodError:org.json.JSONObject.put(String, Collection)</code></h4><p>经检查，引入的包中是存在这个方法的，但是依然报错，</p>
<p>可能原因：包依赖冲突的问题，需要检查<code>org.json</code>包是否引入了多次。</p>
<h4 id="springboot项目-Value取不到值的一些情况"><a href="#springboot项目-Value取不到值的一些情况" class="headerlink" title="springboot项目@Value取不到值的一些情况"></a>springboot项目<code>@Value</code>取不到值的一些情况</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Value(&quot;$&#123;tag&#125;&quot;)</span></span><br><span class="line"><span class="keyword">private</span> String tagValue;</span><br></pre></td></tr></table></figure>
<ul>
<li><p>使用 <code>static</code> 或者 <code>final</code> 修改了 <code>tagValue</code></p>
</li>
<li><p>类上没有加上<code>@Component</code> 或者 <code>@Service</code>注解等</p>
</li>
<li><p>类被 <code>new</code> 新建了实例，而没有使用 <code>@Autowired</code>注解</p>
<p>  若不想使用 <code>@Autowired</code>自动装配，可以使用 <code>ApplicationContext</code>类来获取”bean”</p>
</li>
</ul>
<h4 id="stream中方法peek和map方法之间的区别"><a href="#stream中方法peek和map方法之间的区别" class="headerlink" title="stream中方法peek和map方法之间的区别"></a>stream中方法<code>peek</code>和<code>map</code>方法之间的区别</h4><ul>
<li>peek 可对元素的内部数据进行处理，返回的是原来的数据类型，不生成新的数据类型。</li>
<li>map 重新返回一个新的数据类型。</li>
</ul>
<h4 id="Math-floor-Math-ceil-Math-rint-Math-round用法详解"><a href="#Math-floor-Math-ceil-Math-rint-Math-round用法详解" class="headerlink" title="Math.floor, Math.ceil, Math.rint, Math.round用法详解"></a>Math.floor, Math.ceil, Math.rint, Math.round用法详解</h4><h5 id="Math-floor"><a href="#Math-floor" class="headerlink" title="Math.floor"></a>Math.floor</h5><p>求一个最接近它的整数，它的值小于或等于这个浮点数。</p>
<h5 id="Math-ceil"><a href="#Math-ceil" class="headerlink" title="Math.ceil"></a>Math.ceil</h5><p>它是向上取整计算，它返回的是大于或等于函数参数的值，并且与之最接近的整数。</p>
<h5 id="Math-rint"><a href="#Math-rint" class="headerlink" title="Math.rint"></a>Math.rint</h5><p>它返回最接近参数的整数，如果有两个数同样相近，则返回偶数的那个。</p>
<h5 id="Math-round"><a href="#Math-round" class="headerlink" title="Math.round"></a>Math.round</h5><p>它表示“四舍五入”，算法为<code>Math.floor(x + 0.5)</code>，即将原来的数字加上<code>0.5</code>再向下取整。</p>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/java/" rel="tag"># java</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/01/element-ui%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6%E8%AF%A6%E8%A7%A3/" rel="prev" title="element-ui常用组件详解">
      <i class="fa fa-chevron-left"></i> element-ui常用组件详解
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/01/faq-oracle/" rel="next" title="faq-oracle">
      faq-oracle <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#jdk1-8%E5%A6%82%E4%BD%95%E8%A7%A3%E6%9E%90%E5%92%8C%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%97%A5%E6%9C%9F"><span class="nav-number">1.</span> <span class="nav-text">jdk1.8如何解析和格式化日期</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%A7%A3%E6%9E%90%E6%97%A5%E6%9C%9F%E5%92%8C%E6%97%B6%E9%97%B4"><span class="nav-number">1.1.</span> <span class="nav-text">解析日期和时间</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%97%A5%E6%9C%9F%E5%92%8C%E6%97%B6%E9%97%B4"><span class="nav-number">1.2.</span> <span class="nav-text">格式化日期和时间</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Java8%E4%B8%ADDate%E4%B8%8ELocalDateTime%E3%80%81LocalDate%E3%80%81LocalTime%E4%B9%8B%E9%97%B4%E7%9A%84%E4%BA%92%E8%BD%AC"><span class="nav-number">2.</span> <span class="nav-text">Java8中Date与LocalDateTime、LocalDate、LocalTime之间的互转</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#http%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81"><span class="nav-number">3.</span> <span class="nav-text">http错误代码</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#400"><span class="nav-number">3.1.</span> <span class="nav-text">400</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#EasyPOI%E5%AF%BC%E5%87%BAexcel%E6%96%87%E4%BB%B6%E6%97%B6%EF%BC%8C%E8%8B%A5%E4%B8%8D%E6%83%B3%E5%AF%BC%E5%87%BA%E8%A1%A8%E5%A4%B4%EF%BC%8C%E6%80%8E%E4%B9%88%E8%AE%BE%E7%BD%AE%EF%BC%9F"><span class="nav-number">4.</span> <span class="nav-text">EasyPOI导出excel文件时，若不想导出表头，怎么设置？</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#java%E5%9C%A8%E5%90%8C%E4%B8%80%E8%A1%8C%E4%BB%A3%E7%A0%81%E5%AE%9A%E4%B9%89%E5%A4%9A%E4%B8%AA%E5%8F%98%E9%87%8F"><span class="nav-number">5.</span> <span class="nav-text">java在同一行代码定义多个变量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#i-%E5%92%8C-i-%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="nav-number">6.</span> <span class="nav-text">++i 和 i++ 的区别</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E8%AE%A8%E8%AE%BA-i-%E4%B8%8E-i-%E7%9A%84%E6%95%88%E7%8E%87"><span class="nav-number">6.1.</span> <span class="nav-text">讨论 i++ 与 ++i 的效率</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#spring%E4%B8%AD%E7%9A%84%E6%B3%A8%E8%A7%A3-Component-Repository-Service-Controller-%E7%AD%89%E6%A0%87%E6%B3%A8%E7%9A%84%E9%BB%98%E8%AE%A4-Bean-%E5%90%8D%E7%A7%B0"><span class="nav-number">7.</span> <span class="nav-text">spring中的注解 @Component, @Repository, @Service, @Controller 等标注的默认 Bean 名称</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%8A%A5%E9%94%99%E4%BF%A1%E6%81%AFjava-lang-NoSuchMethodError-org-json-JSONObject-put-String-Collection"><span class="nav-number">8.</span> <span class="nav-text">报错信息java.lang.NoSuchMethodError:org.json.JSONObject.put(String, Collection)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#springboot%E9%A1%B9%E7%9B%AE-Value%E5%8F%96%E4%B8%8D%E5%88%B0%E5%80%BC%E7%9A%84%E4%B8%80%E4%BA%9B%E6%83%85%E5%86%B5"><span class="nav-number">9.</span> <span class="nav-text">springboot项目@Value取不到值的一些情况</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#stream%E4%B8%AD%E6%96%B9%E6%B3%95peek%E5%92%8Cmap%E6%96%B9%E6%B3%95%E4%B9%8B%E9%97%B4%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="nav-number">10.</span> <span class="nav-text">stream中方法peek和map方法之间的区别</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Math-floor-Math-ceil-Math-rint-Math-round%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3"><span class="nav-number">11.</span> <span class="nav-text">Math.floor, Math.ceil, Math.rint, Math.round用法详解</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Math-floor"><span class="nav-number">11.1.</span> <span class="nav-text">Math.floor</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Math-ceil"><span class="nav-number">11.2.</span> <span class="nav-text">Math.ceil</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Math-rint"><span class="nav-number">11.3.</span> <span class="nav-text">Math.rint</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Math-round"><span class="nav-number">11.4.</span> <span class="nav-text">Math.round</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">田园隐士</p>
  <div class="site-description" itemprop="description">talk is cheap, show me the code</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">347</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">53</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">115</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">田园隐士</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">587k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">8:53</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

  

</body>
</html>
